package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.itheima.reggie.common.Msg;
import com.itheima.reggie.common.R;
import com.itheima.reggie.dto.OrderDto;
import com.itheima.reggie.entity.Orders;
import com.itheima.reggie.entity.PageParam;
import com.itheima.reggie.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: java8-reggie
 * @BelongsPackage: com.itheima.reggie.controller
 * @Author: lin
 * @CreateTime: 2022-10-24  13:18
 * @Description:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrdersService orderService;

    @GetMapping("/page")
    public R pageAll(PageParam pageParam){

        IPage<OrderDto> iPage = orderService.pageAll(pageParam);
        return R.success(iPage);
    }
    @PutMapping
    public R update(@RequestBody OrderDto orderDto){
        boolean b = orderService.updateById(orderDto);
        if(b){
            return R.success(Msg.UPDATE_SUCCESS);
        }
        return R.error(Msg.UPDATE_ERROR);
    }

}
